//
//  HomeViewController.m
//  xmppones
//
//  Created by 李立达 on 2017/2/17.
//  Copyright © 2017年 李立达. All rights reserved.
//

#import "HomeViewController.h"

@interface HomeViewController ()
@end
#define navBarHeight 64
@implementation HomeViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self resetBackButton];
    [self resetMiddellable];
    [self resetRightButton];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = COLOR_CONTROLLER_BACKGROUND;

}
/* 通知需要刷新左侧按钮方法 */
- (void)resetBackButton{
    
    UINavigationController  *nav = self.navigationController;
    if ([nav isKindOfClass:[BaseNavigationViewController class]]) {
        
        BaseNavigationViewController *bsNav = (BaseNavigationViewController *)nav;
        bsNav.navdelegate = self;
        [bsNav needResetNavigationBarLeftButton];
    }
}
/* 通知需要刷新中间按钮方法 */
- (void)resetMiddellable{
    UINavigationController  *nav = self.navigationController;
    
    if ([nav isKindOfClass:[BaseNavigationViewController class]]) {
        
        BaseNavigationViewController *bsNav = (BaseNavigationViewController *)nav;
        bsNav.navdelegate = self;
        [bsNav needResetNavigationBarMiddletitle];
    }
}
/* 通知需要刷新右侧按钮方法 */
- (void)resetRightButton{
    // 默认刷新返回按钮不需要动画，子类有需要动画重写次方法
    UINavigationController  *nav = self.navigationController;
    if ([nav isKindOfClass:[BaseNavigationViewController class]]) {
        BaseNavigationViewController *bsNav = (BaseNavigationViewController *)nav;
        bsNav.navdelegate = self;
        [bsNav needResetNavigationBarRightButton];
    }
}

-(UIButton *)returnLeftButton
{
    UIImage *image = [UIImage imageNamed:@"nav_back"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:image forState:UIControlStateNormal];
    [button addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    button.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
    return button;
}
-(void)backButtonAction:(UIButton *)sender
{
      [self.navigationController popViewControllerAnimated:YES];
}

-(UIButton *)returnRightButton
{
    return  nil;
}
-(void)rightBarButtonAction:(UIButton*)sender
{
    
}

-(UILabel *)returntitle
{
    return nil;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
